package value;

import java.util.Random;

/**
 * @Author Mucd
 * @ClassName Max
 * @Date 2020/12/8/008
 * @Specification Alibaba
 */
public class Max {
    public static void main(String[] args) {
        //创建数组
//        int[] arr = {2, 2, 21, 23, 12, 312221, 3, 123, 12};
//        //创建变量储存最大值
//        int maxValue = 0;
//        for (int i = 0; i < arr.length; i++) {
//            //数组的值和 maxValue 的值作比较
//            //将最大值放到maxValue
//            maxValue = Math.max(arr[i], maxValue);
//            System.out.println(maxValue);
//        }

        /*        //创建数组
        int[] arr = {1123, 13223, 132312, 1113, 11233, 121, 2123, 1232};
        //创建变量储存最小值
        int minValue = 0;
        for (int i = 0; i < arr.length; i++) {
            if (arr[i] > minValue) {
                minValue = arr[i];
            }
            System.out.println(minValue);
        }*/
        Max2 m = new Max2();
        m.max2();
    }
}
class Max2{
    public void max(){
        int[] arr = {123,123,12,3,12,312,2412,12,3,123,1238};
        int max = 0;
        for (int i = 0;i<arr.length;i++){
            max = Math.max(arr[i],max);
            System.out.println(max);
        }
    }
    public void max2(){
        Random rd = new Random();
        int rd2 = rd.nextInt();
        int[] arr = {1123,2312,13552,3,12,312,2412,12,3,123,1238};
        int max = 0;
        for (int i = 0; i<arr.length;i++){
            if (arr[i]>max){
                max = arr[i];
                System.out.println(max);
            }
        }
    }
}
